package com.wyz.socket.core.base.packet.file;

import com.wyz.socket.core.base.packet.AbstractReceivePacket;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class FileReceivePacket extends AbstractReceivePacket<File , FileOutputStream> {

    public FileReceivePacket(File file , int length){
        super(length);
        entity = file ;
    }
    @Override
    protected File build(FileOutputStream stream) {
        return entity;
    }

    @Override
    public byte type() {
        return TYPE_STREAM_FILE;
    }

    @Override
    protected FileOutputStream createStream() {
        try {
            return new FileOutputStream(entity);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return null ;
    }
}
